package com.core.framework.web.easyweb.context;

import java.io.Serializable;
import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.core.framework.web.easyweb.EasywebStatics;



/**
 * EasyWeb上下文应用
 * 
 * @author 刘涛
 * @since Jun 12, 2012
 */
public class ServletActionContext extends ActionContext implements  EasywebStatics , Serializable  {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
    @SuppressWarnings("unused")
	public ServletActionContext(Map<String, Object> contextMap) {
		super(contextMap);
	}
    /**
     *  Request setter 
     */
    public static void setRequest(HttpServletRequest request) {
        ActionContext.getContext().put(HTTP_REQUEST, request);
    }

    /**
     * 获取 Request
     */
    public static HttpServletRequest getRequest() {
        return (HttpServletRequest) ActionContext.getContext().get(HTTP_REQUEST);
    }
    /**
     *  Response setter 
     */
    public static void setResponse(HttpServletResponse response) {
    	ActionContext.getContext().put(HTTP_RESPONSE, response);
    }
    
    /**
     * 获取 Response
     */
    public static HttpServletResponse getResponse() {
    	return (HttpServletResponse) ActionContext.getContext().get(HTTP_RESPONSE);
    }
    
    /**
     * 获取 servletContext
     */
    public static ServletContext getServletContext() {
        return (ServletContext) ActionContext.getContext().get(HTTP_SERVLETCONTEXT);
    }

    /**
     *servletContext setter 
     */
    public static void setServletContext(ServletContext servletContext) {
        ActionContext.getContext().put(HTTP_SERVLETCONTEXT, servletContext);
    }
}
